home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 002 / dbug / install.sh < prev    next >
Text File  |  1995-03-17  |  1KB  |  65 lines

  1.  
  2. #    WARNING -- first line intentionally left blank for sh/csh/ksh
  3. #    compatibility.  Do not remove it!  FNF, UniSoft Systems.
  4. #
  5. #    Usage is:
  6. #            install <from> <to>
  7. #
  8. #    The file <to> is replaced with the file <from>, after first
  9. #    moving <to> to a backup file.  The backup file name is created
  10. #    by prepending the filename (after removing any leading pathname
  11. #    components) with "OLD".
  12. #
  13. #    This script is currently not real robust in the face of signals
  14. #    or permission problems.  It also does not do (by intention) all
  15. #    the things that the System V or BSD install scripts try to do
  16. #
  17.  
  18. if [ $# -ne 2 ]
  19. then
  20.     echo  "usage: $0 <from> <to>"
  21.     exit 1
  22. fi
  23.  
  24. # Now extract the dirname and basename components.  Unfortunately, BSD does
  25. # not have dirname, so we do it the hard way.
  26.  
  27. fd=`expr $1'/' : '\(/\)[^/]*/$' \| $1'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \| .`
  28. ff=`basename $1`
  29. td=`expr $2'/' : '\(/\)[^/]*/$' \| $2'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \| .`
  30. tf=`basename $2`
  31.  
  32. # Now test to make sure that they are not the same files.
  33.  
  34. if [ $fd/$ff = $td/$tf ]
  35. then
  36.     echo "install: input and output are same files"
  37.     exit 2
  38. fi
  39.  
  40. # Save a copy of the "to" file as a backup.
  41.  
  42. if test -f $td/$tf
  43. then
  44.     if test -f $td/OLD$tf
  45.     then
  46.         rm -f $td/OLD$tf
  47.     fi
  48.     mv $td/$tf $td/OLD$tf
  49.     if [ $? != 0 ]
  50.     then
  51.         exit 3
  52.     fi
  53. fi
  54.  
  55. # Now do the copy and return appropriate status
  56.  
  57. cp $fd/$ff $td/$tf
  58. if [ $? != 0 ]
  59. then
  60.     exit 4
  61. else
  62.     exit 0
  63. fi
  64.  
  65.